package org.vectrics.recruiter.web;

import javax.security.auth.callback.*;
import java.io.IOException;
import org.apache.log4j.*;

public class CustomLoginCallbackHandler implements CallbackHandler { 
    private static Category log = Category.getInstance(CustomLoginCallbackHandler.class);
    
    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
        for (int i = 0; i < callbacks.length; i++) {
            if (callbacks[i] instanceof NameCallback) {
                log.info("handle() - set name");
                NameCallback nc = (NameCallback)callbacks[i];
                nc.setName("mmoore");
            }
            else if (callbacks[i] instanceof PasswordCallback) {
                log.info("handle() - set password");
                PasswordCallback pc = (PasswordCallback)callbacks[i];
                String password = "rabbit";
                pc.setPassword(password.toCharArray());
            }
        }
    }
    

}


